package com.practice.bootdemo.controller;

import com.practice.bootdemo.annotation.ParamValidate;
import com.practice.bootdemo.entity.TestGen;
import com.practice.bootdemo.service.TestGenService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author :v-zhousq04
 * @description: 测试生成类 controller
 * @create date: 2019-11-30 22:36:44
 * content from code generator
 */

@Slf4j
@RestController
@RequestMapping(value = "testGen")
@Api(value="测试生成类 controller",tags={"测试生成类 信息接口"})
public class TestGenController {

    @Autowired
    TestGenService testGenService;

//    @ApiOperation() 用于方法；表示一个http请求的操作 value用于方法描述,notes用于提示内容, tags可以重新分组（视情况而用）

    @ApiOperation(value = "添加测试生成类信息",httpMethod = "POST" )
    @RequestMapping(value = "add")
    public void add(@RequestBody @ApiParam(name="TestGen",value="测试生成类",required=true)TestGen testGen ){
        Integer resultCount= testGenService.save(testGen);
        return ;
    }


    @ApiOperation(value = "修改测试生成类信息",httpMethod = "POST" )
    @RequestMapping(value = "update")
    public void update(@RequestBody @ApiParam(name="TestGen",value="测试生成类",required=true)TestGen testGen ){
        try {
            //  TODO 处理结果
            Integer resultCount= testGenService.updateById(testGen);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return ;
    }


    //    @ApiOperation() 用于方法；表示一个http请求的操作 value用于方法描述,notes用于提示内容, tags可以重新分组（视情况而用）
    //    paramType 三种值:query ,form ,body 分别对应 get ,form,json格式提交
    @RequestMapping(value = "delete",method = RequestMethod.GET)
    @ApiOperation(value = "删除测试生成类信息",httpMethod = "GET" )
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value="测试生成类Id",required=false,paramType="query"),
            @ApiImplicitParam(name="name",value="测试生成类名称",required=false,paramType="query")
    })
    @ParamValidate
    public void delete(Integer id ,String name)  {
        try {
            //  TODO 处理结果
            Integer resultCount= testGenService.deleteById(id);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return ;
    }

    @ApiOperation(value = "查询测试生成类信息",httpMethod = "POST" )
    @RequestMapping(value = "findList",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public void findList(@RequestBody @ApiParam(name="TestGen",value="测试生成类",required=true)TestGen testGen ){
        try {
            //  TODO 处理结果
            List<TestGen> testGenList= testGenService.findList(testGen);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return ;
    }

    @ApiOperation(value = "查询测试生成类信息",httpMethod = "GET" )
    @RequestMapping(value = "findById/{id}")
    public void findById(@PathVariable @ApiParam(name="id",value="测试生成类 id",required=true)Integer id) throws Exception {
        /*try {
            //  TODO 处理结果
            TestGen testGen= testGenService.find(id);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return ;*/
        throw new Exception("test exception");
    }

}
